package com.gmako.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmako.dao.BaseDAO;
import com.gmako.entity.Businessimg;
import com.gmako.entity.Packageinfo;
import com.gmako.entity.Packimg;
import com.gmako.entity.Userinfo;
import com.gmako.service.PackageinfoService;

@Service
public class PackageinfoServiceImpl implements PackageinfoService{
	@Autowired
	private BaseDAO baseDAO;

	/**
	 * 添加套餐信息
	 * @author Warlock
	 * @param P
	 */
	public void addpackageInfo(Packageinfo packageinfo) {
		baseDAO.save(packageinfo);
	}
	
	/**
	 * 添加详细图片
	 * @author Warlock
	 * @param Packimg
	 * @return
	 */
	public void save(Packimg packimg){
		baseDAO.save(packimg);
		
	}

	/**
	 * 通过Id获取帐号
	 * @author Warlock
	 * @param id
	 * @return
	 */
	public Userinfo getCount(int id) {
		String hql="from Userinfo where id="+id;
		return  (Userinfo)baseDAO.loadObject(hql);
	}
	
	/**
	 * 活动套餐图片
	 * @param id
	 * @return
	 */
	public Packimg getPackimg(int id) {
		String hql="from Packimg where packageId="+id;
		return  (Packimg)baseDAO.loadObject(hql);
	}
	
	/**
	 * 根据PackageID 查询套餐图片
	 * @param PackageID
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Packimg> findPackageImgs(int pid) {
		return baseDAO.findByProperty("Packimg","packageId", pid);	
	}
	
  /**
	 * 获得套餐对象
	 * @param id
	 * @return
	 */
	public Packageinfo getPackageinfo(int id) {
		String hql="from Packageinfo where id="+id;
		return  (Packageinfo)baseDAO.loadObject(hql);
	}



}
